/***************************************************************************
                          main.c  -  description
                             -------------------
    begin                : Mon Dec  9 11:33:47 CST 2002
    copyright            : (C) 2002 by Liming Xie
    email                : liming_xie@yahoo.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>

//#include "nodeconf.h"
#include "core_mod.h"
// #include "srvutils/utils_conf.h"
#if 1

static FilterModule sndsvr_filtermodule;

extern int SND_initialize( ConfUnit * mod_conf );
extern int SND_terminate( ConfUnit * mod_conf );
extern int SND_post_terminate( void );

static int sndsvr_filtermodule_initialize( void )
{
	ConfUnit *mod_conf = sndsvr_filtermodule.conf;

	if( sndsvr_filtermodule.status != MOD_STATUS_FRESH )
	{
		fprintf( stderr, "[mod_sndsvr] - try to init again!\n" );
		return -1;
	}

	/* initialize sound device */
	SND_initialize( mod_conf );
	sndsvr_filtermodule.status = MOD_STATUS_RUNNING;
	return 0;
}

static int sndsvr_filtermodule_terminate( void )
{
	ConfUnit *mod_conf = sndsvr_filtermodule.conf;

	/* close sound devices */
	SND_terminate( mod_conf );
	return 0;
}

static int sndsvr_filtermodule_post_term( void )
{
	/* close sound devices */
	SND_post_terminate();
	sndsvr_filtermodule.status = MOD_STATUS_CLOSED;
	return 0;
}

static FilterModule sndsvr_filtermodule = {
	sizeof(FilterModule),
	FMVER_YMD(2005,2,28),
	"mod_sndsvr",
	"Duplex sound I/O and PA service to multiple apps.",
	MOD_STATUS_FRESH,
	sndsvr_filtermodule_initialize,
	NULL,
	sndsvr_filtermodule_terminate,
	sndsvr_filtermodule_post_term,
	NULL,
};

FilterModule* get_module( void )
{
	return & sndsvr_filtermodule;
}

#endif
